package com.mystudy.jcu.countDownLatch;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

/**
 * TODO:{@link CountDownLatch}测试
 * countDown:当前执行完等待的线程数减1
 * await：当前线程进行等待
 * @author acy
 * @since 2019/06/17 17:36
 */
public class CountDownLatchTest3 {
	public static void main(String[] args) throws InterruptedException {
		CountDownLatch latch = new CountDownLatch(1);
		Thread mainThread=Thread.currentThread();
		new Thread(()->{
			try {
				Thread.sleep(10000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			latch.countDown();
			mainThread.interrupt();
		}).start();
		latch.await(1000,TimeUnit.MILLISECONDS);
		System.out.println("=================");
	}
}
